package cn.wolfcode.tieba.util;

import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;

import java.io.IOException;

public class SpiderUtil {
    public static void doGet(String uri) throws IOException {
        CloseableHttpClient client = HttpClients.createDefault();
        HttpGet get = new HttpGet(uri);
        CloseableHttpResponse response = client.execute(get);
        System.out.println(response.getStatusLine().getStatusCode());
        HttpEntity entity = response.getEntity();
        String res = EntityUtils.toString(entity, "utf-8");
        System.out.println(res);
        client.close();
    }

    public static void main(String[] args) throws IOException {
        doGet("https://tieba.baidu.com/p/6509957010");
    }
}